﻿using System;
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Data;
using Coding4Fun.Phone.Controls;
using EbbinghausWord.Common;
using EbbinghausWord.Entities;
using Microsoft.Phone.Controls;

namespace EbbinghausWord.BLL
{
    /// <summary>
    /// 通用工具类
    /// </summary>
    public static class Tools
    {
        /// <summary>
        /// 将列表中的元素添加到队列中
        /// </summary>
        /// <param name="wordList"></param>
        /// <param name="queue"></param>
        [Obsolete]
        public static void AddToQueue(this List<WordEntity> wordList, Queue<WordEntity> queue)
        {
            foreach (var wordEntity in wordList)
            {
                queue.Enqueue(wordEntity);
            }
        }

        /// <summary>
        /// 将日期转换成EW标准字符串格式
        /// </summary>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        public static string ToEWDateFormat(this DateTime dateTime)
        {
            return dateTime.ToString("yyyy-MM-dd");
        }


        /// <summary>
        /// 显示提示信息
        /// </summary>
        /// <param name="title"></param>
        /// <param name="message"></param>
        public static void ShowMessage(string title, string message)
        {
            new ToastPrompt() { Title = title, Message = message }.Show();
        }

        /// <summary>
        /// 显示提示信息
        /// </summary>
        /// <param name="message"></param>
        public static void ShowMessage(string message)
        {
            ShowMessage("", message);
        }

        /// <summary>
        /// 设置ToggleSwitch显示中文
        /// </summary>
        /// <param name="toggleSwitch"></param>
        public static void SetToggleSwitchWithChinese(ToggleSwitch toggleSwitch)
        {
            toggleSwitch.SetBinding(
                ContentControl.ContentProperty, new Binding("IsChecked")
                {
                    Source = toggleSwitch,
                    Converter = new ChineseOffOnConverter()
                });
        }
    }
}
